package com.ijustyce.denoise.Adapter;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.recyclerview.widget.RecyclerView;


import com.ijustyce.denoise.Items.goods;
import com.ijustyce.denoise.R;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

public class MyAdapter extends RecyclerView.Adapter<MyAdapter.ViewHolder> {


    List<goods> List = new ArrayList<>();
    List<goods> goodsList1 = new ArrayList<>();
    private List<Map<String,goods>> list= new ArrayList<>();
    private goods good;


//    private JSONArray jsonArray;

    public static class ViewHolder extends RecyclerView.ViewHolder {
        ImageView Image;
        TextView Name;
        TextView Price;
        TextView trait;

        public ViewHolder(View view) {
            super(view);
            Image = (ImageView) view.findViewById(R.id.iv);
            Name = (TextView) view.findViewById(R.id.tv_summary);
            Price=(TextView)view.findViewById(R.id.tv_title);
            trait=(TextView)view.findViewById(R.id.tv_user_name);
        }
    }

    public MyAdapter(List<goods> fruitList) {
        List = fruitList;
    }

    @Override
    public ViewHolder onCreateViewHolder(final ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item, parent, false);
            final ViewHolder holder = new ViewHolder(view);
            return holder;
    }

    @Override
    public void onBindViewHolder(ViewHolder holder, int position) {

        System.out.println("aaaaa"+position);

        goods good = List.get(position);
        holder.Name.setText(good.gettitle());
//        holder.Image.setImageResource(good.getImageId());
        holder.Price.setText(good.getPrince());
        holder.trait.setText(good.gettrait());
    }

    @Override
    public int getItemCount() {
        return List.size();
    }

    @Override
    public long getItemId(int position) {
        return super.getItemId(position);
    }

}
